package cn.nangzi.study.oauth.repository;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import cn.nangzi.study.oauth.model.Authority;

@Service
public class CustomUserDetailsService implements UserDetailsService {

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		// TODO 此处需改为从数据库获取
		String name = "nangzi";
		String password = "nangzi";
		List<Authority> authorities = new ArrayList<Authority>();
		authorities.add(new Authority(1L, "ROLE_ADMIN"));
		
		return new User(name, password, true, true, true, true, authorities);
	}

}